package com.foreknow.mapper;

import com.foreknow.entity.Scheduling;
import org.apache.ibatis.annotations.*;

import java.time.LocalDate;
import java.util.List;

@Mapper
public interface SchedulingMapper {

    /**
     * 查询排班计划(具体时间和个人)
     * @param userId
     * @param noon
     * @param date
     * @return
     */
    @Select("select * from scheduling where UserID = #{userId} and Noon = #{noon} and SchedDate = #{date}")
    public Scheduling getScheduling(Integer userId,String noon, LocalDate date);

    /**
     * 查询排班计划(范围日期和具体个人)
     * @param userId
     * @param startDate
     * @param endDate
     * @return
     */
    @Select("select * from scheduling where UserID = #{userId} and SchedDate between #{startDate} and #{endDate}")
    public List<Scheduling> getSchedulings(Integer userId, LocalDate startDate, LocalDate endDate);

    /**
     * 添加排班数据
     * @param scheduling
     * @return
     */
    @Insert("insert into scheduling (SchedDate,DeptID,UserID,Noon,RuleID,DelMark) value (#{schedDate},#{deptId},#{userId},#{noon},#{ruleId},1)")
    public int addScheduling(Scheduling scheduling);

    /**
     * 删除排班数据
     * @param schedId
     * @return
     */
    @Delete("delete from scheduling where ID = #{schedId}")
    public int deleteScheduling(Integer schedId);
}
